#include <QFileDialog>

#include "mainwindow.h"
#include "testwindow.h"
#include "ui_mainwindow.h"
#include "newuserwindow.h"


/**
 * @file mainwindow.cpp
 * @author  Paweł Hanejko <phanejko@gmail.com>
 * @version 1.0
 *
 * @section LICENSE
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details at
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @section DESCRIPTION
 * Plik źródłowy zawiera implementację głównego okna aplikacji.
 *
 *
 */

const QString MainWindow::basefile="base.dat";

void MainWindow::updateUsers()
{
    BaseReader r;
    users= r.read(basefile);
}


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    updateUsers();

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_newUser_clicked()
{

    NewUserWindow* w =new NewUserWindow(this);
    w->show();

}

void MainWindow::on_testUser_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Test image"),
                                                    "/home",tr("Images (*.jpeg *.jpg)"));
    TestWindow* w =new TestWindow(this);

    if(fileName!=NULL && !fileName.isEmpty()) w->show();


    if(w->test(fileName))
    {
        int x=7;
    }
    else
    {
        int y=9;
    }



}
